<?php
namespace Common\Controller;
use Think\Controller;
class BaseController extends Controller{
	public function __construct(){
		parent:: __construct();
		if(!session('?name')){
			$this-> error('没有登录',U('Login/Login'));
		}
		$this-> Menus();
		//$this-> judgeRoot();
		$this-> Menus();
	}
private function Menus(){
		$where = [
			'lock' => '1',
		];
		$res = M('menus')-> where($where)-> order('mgroup asc,msort asc')-> select();//dump($res);
		$this-> assign('nav', $res);
		
	}
	private function judgeRoot(){
		$url = MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME;
		$menu_id = M('menus')-> getFieldByurl($url,'menu_id');
		if(in_array($menu_id,session('role')) == false){
			$this-> error('你没有权限',U('Login/login'));
			//dump($menu_id);
			//dump(session('role'));
		}
	}


	
}
	
	

